﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimplifyLauncher
{
    public class Launcher
    {
        private Dictionary<int, Shortcut> shortcuts; // Dictionary of shortucts, int is the location rectangle index
        private int screenWidth, screenHeight; // Screen width and height calculated using primary screen bounds
        private int iconWidth, iconHeight; // Width and height drawn for all icons in the launcher
        private int rows, columns, pages; // Number of rows/columns per page and number of pages

        // These values are used if the user hasn't defined preview divisor, icon width, icon height, rows, or columns
        const int DEFAULT_ICON_WIDTH = 140;
        const int DEFAULT_ICON_HEIGHT = 140;
        const int DEFAULT_ROWS = 3;
        const int DEFAULT_COLUMNS = 4;
        const int DEFAULT_PAGES = 1;

        /// <summary>
        /// Constructor generates a launcher with default icon width, icon height, rows, and columns.
        /// </summary>
        public Launcher()
            : this(DEFAULT_ICON_WIDTH, DEFAULT_ICON_HEIGHT, DEFAULT_ROWS, DEFAULT_COLUMNS, DEFAULT_PAGES) {}

        /// <summary>
        /// Constructor generates a launcher with user defined icon width, icon height, rows, and columns.
        /// </summary>
        public Launcher(int iconWidth, int iconHeight, int rows, int columns, int pages)
        {
            // Initialize dictionary for shortcuts and their corresponding indices
            shortcuts = new Dictionary<int, Shortcut>();
            screenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
            screenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;

            // Get icon width, icon height, rows, and columns defined in the constructor
            // Initialize corresponding global variables
            this.iconWidth = iconWidth;
            this.iconHeight = iconHeight;
            this.rows = rows;
            this.columns = columns;
            this.pages = pages;

// DELETE THIS SECTION... FOR TESTING ONLY...
            shortcuts.Add(0, new Shortcut("Test Shortcut", "hey", "test", "../../Test.png"));
// END...
        }

        public Dictionary<int, Shortcut> Shortcuts
        {
            get { return shortcuts; }
        }

        public int ScreenWidth
        {
            get { return screenWidth; }
        }

        public int ScreenHeight
        {
            get { return screenHeight; }
        }

        public int IconWidth
        {
            get { return iconWidth; }
            set { iconWidth = value; }
        }

        public int IconHeight
        {
            get { return iconHeight; }
            set { iconHeight = value; }
        }

        public int Rows
        {
            get { return rows; }
            set { rows = value; }
        }

        public int Columns
        {
            get { return columns; }
            set { columns = value; }
        }

        public int Pages
        {
            get { return pages; }
            set { pages = value; }
        }
    }
}
